package com.hmall.search.mq;

import com.hmall.search.constatnts.MqConstatnts;
import com.hmall.search.service.ISearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemListener {
    @Autowired
    private ISearchService searchService;

    @RabbitListener(queues = MqConstatnts.HOTEL_INSERT_QUEUE)
    public void listenInsertOrUpdate(Long id) {
        searchService.insertById(id);
    }

    @RabbitListener(queues = MqConstatnts.HOTEL_DELETE_QUEUE)
    public void listenDelete(Long id) {
        searchService.deleteById(id);
    }
}
